package com.wy.shopping.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wy.common.utils.PageUtils;
import com.wy.common.utils.Query;

import com.wy.shopping.dao.GoodsDao;
import com.wy.shopping.entity.GoodsEntity;
import com.wy.shopping.service.GoodsService;


@Service("goodsService")
public class GoodsServiceImpl extends ServiceImpl<GoodsDao, GoodsEntity> implements GoodsService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<GoodsEntity> wrapper = new QueryWrapper<>();
        String goodsName = (String) params.get("goodsName");
        if (StringUtils.isNotEmpty(goodsName)) {
            wrapper.like("goods_name",goodsName);
        }

        IPage<GoodsEntity> page = this.page(
                new Query<GoodsEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}